﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using OperaHouse.Domain.Users;

namespace OperaHouse.Web.Models
{
    public class UserModel
    {
        public int Id { get; set; }

        [StringLength(100)]
        [Required(ErrorMessage = "Username is required.")]
        [RegularExpression(@"^[a-zA-Z0-9\._]{3,20}$", ErrorMessage = "User name can only contain 0...9, a...Z, the stop and underline char, min 3 chars.")]
        public string Username { get; set; }

        [StringLength(50)]
        [DataType(DataType.Password)]
        [Required(ErrorMessage = "Password is required.")]
        public string Password { get; set; }

        public static UserModel Create(User user)
        {
            var userModel = new UserModel();
            userModel.Id = user.Id;
            userModel.Username = user.Username;
            userModel.Password = user.Password;
            return userModel;
        }
    }
}